﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Xna.Framework.Input;
using Phoenix.Xna.Framework.Input;


namespace InputBindingStudio
{
    using Phoenix.Xna.Framework.Input.Binding;

    /// <summary>
    /// Interaction logic for BindingDialog.xaml
    /// </summary>
    public partial class BindingDialog : Window
    {
        private bool _isRecording;

        public InputBinding Binding { get; set; }

        public BindingDialog()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //Binding = new InputBinding()
            //{
            //    Action = _action.Text,
            //    DeviceType = (DeviceType)_deviceType.SelectedItem,
            //    SubType = (DeviceSubType)_deviceSubType.SelectedItem,
            //    Value = _value.SelectedItem.ToString()
            //};
            DialogResult = true;
            Close();
        }

        private void _inputData_MouseDown(object sender, MouseButtonEventArgs e)
        {
            _isRecording = true;
        }

        private void button1_KeyDown(object sender, KeyEventArgs e)
        {            
        }

        private void OnDeviceTypeChanged(object sender, SelectionChangedEventArgs e)
        {
            DeviceType deviceType = (DeviceType)_deviceType.SelectedItem;
            _deviceSubType.SelectedIndex = -1;
            List<DeviceSubType> subTypes = new List<DeviceSubType>();

            switch (deviceType)
            {
                case DeviceType.Keyboard:
                    subTypes.Add(DeviceSubType.KeyboardKey);
                    _deviceSubType.ItemsSource = subTypes;
                    break;
                case DeviceType.Mouse:
                    subTypes.Add(DeviceSubType.MouseAxis);
                    subTypes.Add(DeviceSubType.MouseButton);
                    subTypes.Add(DeviceSubType.MouseScrollwheel);
                    _deviceSubType.ItemsSource = subTypes;
                    break;
                case DeviceType.GamePad:
                    _deviceSubType.ItemsSource = null;
                    break;
            }
        }

        private void OnDeviceSubTypeChanged(object sender, SelectionChangedEventArgs e)
        {
            DeviceSubType subType = (DeviceSubType)_deviceSubType.SelectedItem;

            switch (subType)
            {
                case DeviceSubType.KeyboardKey:
                    _value.ItemsSource = Enum.GetValues(typeof(Keys));
                    break;
                case DeviceSubType.MouseAxis:
                    break;
                case DeviceSubType.MouseButton:
                    break;
                case DeviceSubType.MouseScrollwheel:
                    break;
            }
        }
    }
}
